process {

    publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

    withName: STAR_GENOMEGENERATE {
        ext.args = '--genomeSAindexNbases 9'
    }

    withName: STAR_ALIGN {
        ext.args = '--readFilesCommand zcat'
    }

    withName: '.*:BAM_SORT_STATS_SAMTOOLS_.*:SAMTOOLS_.*' {
        ext.prefix = { "${meta.id}.sorted" }
    }

    withName: '.*:BAM_SORT_STATS_SAMTOOLS_.*:BAM_STATS_SAMTOOLS:.*' {
        ext.prefix = { "${meta.id}.sorted.bam" }
    }

}
